(toggle-word-wrap): New command.
authorJuri Linkov <juri@jurta.org>
Sun, 8 Feb 2009 00:46:38 +0000 (00:46 +0000)
committerJuri Linkov <juri@jurta.org>
Sun, 8 Feb 2009 00:46:38 +0000 (00:46 +0000)
lisp/simple.el

index 950d7f0730d1a61da8410021e004e44cf685a438..cb2459a7348744309047a586316f5a846c9e9730 100644 (file)
@@ -5079,6 +5079,21 @@ is non-nil."
   (message "Truncate long lines %s"
           (if truncate-lines "enabled" "disabled")))
 
+(defun toggle-word-wrap (&optional arg)
+  "Toggle whether to use word-wrapping for continuation lines.
+With prefix argument ARG, wrap continuation lines at word boundaries
+if ARG is positive, otherwise wrap them at the right screen edge.
+This command toggles the value of `word-wrap'.  It has no effect
+if long lines are truncated."
+  (interactive "P")
+  (setq word-wrap
+       (if (null arg)
+           (not word-wrap)
+         (> (prefix-numeric-value arg) 0)))
+  (force-mode-line-update)
+  (message "Word wrapping %s"
+          (if word-wrap "enabled" "disabled")))
+
 (defvar overwrite-mode-textual " Ovwrt"
   "The string displayed in the mode line when in overwrite mode.")
 (defvar overwrite-mode-binary " Bin Ovwrt"